package com.zzyl.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.DeptDto;
import com.zzyl.service.DeptService;
import com.zzyl.vo.DeptVo;
import com.zzyl.vo.TreeVo;
import io.swagger.annotations.ApiImplicitParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/dept")

public class DeptController {
    @Autowired
    private DeptService deptService;
    @RequestMapping("/list")
    @ApiImplicitParam(name = "deptDto",value = "部门DTO对象",required = true,dataType = "DeptDto")
    @ApiOperationSupport(
            includeParameters = {"deptDto.dataState","deptDto.deptName","deptDto.parentDeptNo"}
    )
    public ResponseResult<List<DeptVo>> deptList(@RequestBody DeptDto deptDto){
        List<DeptVo> deptVoList = deptService.findDeptList(deptDto);
        return ResponseResult.success(deptVoList);
    }
    @PostMapping("/tree")
    public ResponseResult<TreeVo> deptTree(){
        TreeVo deptVoList = deptService.deptTreevo();
        return ResponseResult.success(deptVoList);
    }
}
